<?php
	
	namespace Aspic\Route;
	use Aspic\Security\Security as S;

	abstract class AbstractRoute {
		
		protected $_from;
		protected $_to;
		
		/**
		 *
		 * @param string $from Route Pattern
		 * @param mixed $to Route data (This data will be return as the "data" key if the current route matches
		 */
		public function __construct($from, $to) {
			$this->_from = $from;
			$this->_to = $to;
		}

		public function getActionPath() {
			return $this->_to;
		}
		
		abstract public function match($src);

        /**
         * @param array $params
         * @param bool $encodeParams Define if params will be encoded in the url
         * @return
         */
		abstract public function reverseRoute(array $params = array(), $encodeParams);
		
		/**
		 * Return an array like array('data' => 'dataAssociateWithRoute',  'params' => array('p1' => 'v1'))
		 */
		abstract public function parse($src);
		
		public function throwActionDataError() {
			throw new \Exception('Route path ('.S::escapeXss($this->to).') does not return a valid path (module/controller/action)');
		}
		
	}
	
?>